Methods and apparatus for compressed and compacted virtual memory

ABSTRACT

A method and an apparatus for a memory device including a dynamically updated portion of compressed memory for a virtual memory are described. The memory device can include an uncompressed portion of memory separate from the compressed portion of memory. The virtual memory may be capable of mapping a memory address to the compressed portion of memory. A memory region allocated in the uncompressed portion of memory can be compressed into the compressed portion of memory. As a result, the memory region can become available (e.g. after being compressed) for future allocation requested in the memory device. The compressed portion of memory may be updated to store the compressed memory region. The compressed memory region may be decompressed back to the uncompressed portion in the memory device in response to a request to access data in the compressed memory region.

FIELD OF INVENTION

The present invention relates generally to memory systems. Moreparticularly, this invention relates to compressed and/or compactedmemory for virtual memory systems.

BACKGROUND

Virtualization techniques have been developed to enhance memorymanagement for memory space having a size exceeding actual physicalcapacity of a memory device. Typically, memory virtualization can bebased on memory swapping using a storage device coupled to the memorydevice. As memory objects and/or IO (input/output) sizes are notdeterministic, different sizes or pages of memory which are uncompressedmay be swapped in/out between the storage and memory devices. As aresult, IO through put and/or latency for transferring stored memorydata for the swap memory may negatively impact the performance of thevirtual memory system.

Further, the performance of certain storage devices, such as spin basedhard disks, may have strong dependency on data locality for memoryaccess to reduce lengthy disk spins. However, data locality may not beguaranteed during runtime as clustering characteristics for memoryaccess vary in different data processing tasks. Thus, memory swapping bypaging in/out between the memory device and the storage device tosupport generic data processing tasks can further degrade the perceivedperformance of the memory system.

Although the trend of adopting larger and larger sizes of actualphysical memory tends to alleviate performance cost in inter devicememory swap, certain feature enhancements in data processing systems maybe provided without memory size changes. For example, support for higherscreen resolution may be imposed on existing devices based onsubstantially the same amount of memory size. However, a mere two timeshigher screen resolution may correspond to four times increase in windowbuffer sizes. As a result, without a compensating increase in physicalmemory size, the system performance for higher screen resolution maydegrade and become visibly slower.

Therefore, traditional implementations of virtual memory systems are notcapable of supporting performance requirements constrained by limitedphysical memory sizes.

SUMMARY OF THE DESCRIPTION

A compressed memory pool dynamically maintained in a memory device canprovide an additional layer of support for a virtual memory based on thememory device coupled with a mass storage device. Virtual memoryaddresses may be paged or mapped into an uncompressed portion of thememory device, the compressed memory pool and/or the storage device. Thecompressed memory pool may grow and shrink within the memory devicewithout a size limitation for the virtual memory.

In one embodiment, a memory page (e.g. a unit of area of uncompressedmemory) may be compressed into a compressed memory unit (or compressedpage) in the compressed memory. Multiple compressed memory units may becompacted together as a fixed sized segment in the compressed memory.The segment may be sized for efficient data transfer between the memorydevice and the mass storage device for swapping in/out segments ofcompressed memory units to support a virtual memory pager.

In another embodiment, a memory device may include a dynamically updatedportion of compressed memory for a virtual memory. The memory device caninclude an uncompressed portion of memory separate from the compressedportion of memory. The virtual memory may be capable of mapping a memoryaddress to the compressed portion of memory. A memory region allocatedin the uncompressed portion of memory can be compressed into thecompressed portion of memory. As a result, the memory region can becomeavailable (e.g. after being compressed) for future allocation requestedin the memory device. The compressed portion of memory may be updated tostore the compressed memory region. The compressed memory region may bedecompressed back to the uncompressed portion in the memory device inresponse to a request to access data in the compressed memory region.

In another embodiment, a virtual memory based on a memory device isprovided. The memory device can be dynamically partitioned into anuncompressed portion of memory and a compressed portion of memory, suchas DRAM (volatile memory). The uncompressed portion of memory can storeworking data processed via a processor coupled to the memory device. Oneor more pages of the uncompressed portion of memory can be compressedinto one or more varied sized compressed memory units in the compressedportion of memory. The compression can increase available memory spacein the uncompressed portion of memory. The compressed memory units canbe decompressed back from the compressed portion of memory to theuncompressed portion of memory, for example, in response to a page faultfor an access request to data in one of the compressed memory units. Atleast one of the varied sized compressed memory units can be swapped outfrom the compressed portion of memory to a mass storage device toincrease available memory space in the uncompressed portion of memory.

In another embodiment, one or more memory pages of an uncompressedportion of a memory device can be compressed into one or more variedsized compressed memory units in a compressed portion of the memorydevice. A mass storage device (such as a magnetic hard drive (HDD) or acomposite storage device, treated as one logical volume from a filesystem's perspective, that includes an HDD and flash memory) can becoupled with the memory device. The varied sized compressed memory unitscan be compacted into a segment in the compressed portion of the memorydevice. The one compressed memory unit can be decompressed from thecompressed portion to the uncompressed portion of the memory device inresponse to an access request to one of the compressed memory units. Thesegment of the compressed memory units may be swapped out to the massstorage device to increase available memory space in the memory device.

Other features of the present invention will be apparent from theaccompanying drawings and from the detailed description that follows.

BRIEF DESCRIPTION OF THE DRAWINGS

The present invention is illustrated by way of example and notlimitation in the figures of the accompanying drawings, in which likereferences indicate similar elements and in which:

FIG. 1 is a block diagram illustrating one embodiment of a virtualmemory system based on compressed and/or compacted memory;

FIG. 2 is a flow diagram illustrating one embodiment of compressing anddecompressing memory for a virtual memory;

FIG. 3 is a flow diagram illustrating one embodiment of a process toswap compressed memory pages for a virtual memory;

FIG. 4 is a flow diagram illustrating one embodiment of a process toswap a compacted segment of compressed memory for a virtual memory;

FIG. 5 illustrates one example of a data processing system such as acomputer system, which may be used in conjunction with the embodimentsdescribed herein.

DETAILED DESCRIPTION

Methods and apparatuses for compressed and compacted virtual memory aredescribed herein. In the following description, numerous specificdetails are set forth to provide thorough explanation of embodiments ofthe present invention. It will be apparent, however, to one skilled inthe art, that embodiments of the present invention may be practicedwithout these specific details. In other instances, well-knowncomponents, structures, and techniques have not been shown in detail inorder not to obscure the understanding of this description.

Reference in the specification to “one embodiment” or “an embodiment”means that a particular feature, structure, or characteristic describedin connection with the embodiment can be included in at least oneembodiment of the invention. The appearances of the phrase “in oneembodiment” in various places in the specification do not necessarilyall refer to the same embodiment.

The processes depicted in the figures that follow, are performed byprocessing logic that comprises hardware (e.g., circuitry, dedicatedlogic, etc.), software (such as is run on a general-purpose computersystem or a dedicated machine), or a combination of both. Although theprocesses are described below in terms of some sequential operations, itshould be appreciated that some of the operations described may beperformed in different order. Moreover, some operations may be performedin parallel rather than sequentially.

In one embodiment, a compression pool (or pool of compressed memoryunits) in a memory device may by managed dynamically using log baseddata structures (or log structures). Data can be put in the compressionpool in a packed and/or compressed manner to shrink required memoryspace for storing the data. When to swap stored data between thecompression pool and a mass storage device (or nonvolatile storagedevice) may be automatically determined in a self contained compressedmemory management system, for example, to insulate a virtual memorysystem or other applicable memory usage module, from the underlyingcompression pool.

Memory data may be compressed to reduce swap file size, for example, fordata transfer efficiency between a memory device and a swap device suchas a mass storage device. Additionally, memory data may be compressedinto a compression pool based on efficient memory compression schemeswith compression/decompression cost (e.g. in several micro seconds)significantly less (e.g. several orders of magnitudes) than conventionaldisk swap speed with a swap device. The compression pool may grow insize within the memory device when needed to reduce required swappingoperations with the swap device.

For example, the compression pool can grow and work as large as theavailable physical memory size as long as there is enough memory spaceleft (e.g. a small number of memory pages) to perform memorycompression/decompression operations to shift data in/out of thecompression pool. A working set may be maintained to fit in theuncompressed portion of memory with varied sizes as the compression poolgrows/shrinks. If the working set (e.g. memory allocated for a set oflive tasks for data operations of a processor) spills into thecompression pool (or compressed portion of memory), memory pages may bepulled (e.g. based on a certain predetermined rate) from the compressedportion to substitute between the compressed and uncompressed portions(or layers) of memory to support the working set. Requests orrequirements for additional memory space to allocate may be detected toindicate that the existing working set has spilled over. The working setmay be extended via a LRU (least recently used) ordering strategy toselect which memory pages to be compressed into the compression pool.

In one embodiment, multiple compression/decompression schemes ormechanisms may be dynamically selected during run time. Each scheme maybe based on one or more compression/decompression algorithms. Theselection may be made based on a hint or heuristic provided by thecreator (e.g. an application or process initiating or requestingallocation) of the memory, or it could be determined by looking in eachpage of memory about to be compressed for a particular pattern of data.In one embodiment, one of the compression/decompression schemes may bedesignated as the default one applicable to a majority of allocatedmemories (e.g. without any hint provided by corresponding memorycreators). This scheme would also be used as the default one if apattern matching mechanism was in play, and no match was made. Onecandidate that might benefit (e.g. see more efficient compression) froma specialized compression/decompression scheme is the memory created foruse by graphics operations (e.g. via a GPU).

In some embodiments, compaction operations may be performed in thecompression pool to maintain log structures in the compressed memorysegments. For example, compressed data units may be packed togetherwithin one compression memory segment (e.g. for minor compaction) and/oracross multiple compression memory segments (e.g. for major compaction).Compaction operations may be initiated on requests and/or automaticallyas compressed data are removed from or stored into the compressedmemory. Log structures may allow efficient input/output operations (e.g.read/write operations) on the compression pool within a memory deviceand/or between coupling storage devices.

According to one embodiment, as compressed data is pulled out from thecompression pool, holes (i.e. empty memory space previously occupied bythe compressed data) may be created. As a result, memory usage of thecompression pool may become less and less efficient if these holes arenot removed. Minor compaction operations can be performed to movecompressed data within a memory segment (e.g. a log structure) in thecompression pool to reduce number of holes in the memory segment. In oneembodiment, minor compaction operations may be performed to allowadditional allocation of memory pages in the memory device. Minorcompaction operations may cost insignificant processing resources tocause noticeable improvement in data processing latency.

In one embodiment, major compaction operations may be performed to movecompressed data among different memory segments of the compression poolin addition to minor compaction operations, for example, when there is aneed to swap compressed data out to a swap device. The number of memorysegments required in the compression pool may be reduced as a result ofthe major compaction operations. Unused memory space in memory segmentsof the compression pool may be tightened up (or reduced), for example,to allow writing out large chunks of compressed memory pages to a swapdevice. As a result, available IO bandwidth (e.g. between the memorydevice and the swap device) can be maximized. Further, the amount ofware and tear against the swap device (such as a SSD device) can beminimized.

In one embodiment, compaction operations are performed based on acompaction model which determines when to perform minor compactionoperations, major compaction operations or other applicable datamovement operations to maintain efficient memory storage usage in thecompression pool. Minor compaction operations may be performed toshuffle compressed data within one memory segment to increase or releaseavailable memory space. Major compaction operations may be performed tomove compressed data among multiple memory segments, for example, toensure readiness to swap out memory segments in full size from thecompression pool to a swap device. A memory segment may be in full sizeif it is substantially without holes or with a memory usage rate greaterthan, for example, a predetermined threshold (e.g. 99%).

Thus, log structured data (or model) can be maintained when performingIO operations writing to swap files (e.g. in a swap device) from thecompression pool, for example, based on same sized chunk of data (e.g. acompression segment), such as 256 KB, 512 KB, 1024 KB or other suitablesize. In one embodiment, the chunk of data transferred during the IOoperation for memory swapping may correspond to a collection ofcompression memory pages according to the IO interface with the swapdevice (e.g. matching an IO bus buffer size) to improve IO performance.Consequently, efficiency or through put in IO operations between thecompression pool and the swap device may be improved based on thecompression of the data transferred and the matching transfer data chunksize for the swap device.

In one embodiment, log structured data in the compression pool mayinclude an ordered list of memory segments. Newly compressed data may berecorded in the head segment (or recording head) of the ordered segmentlist. Working set analysis for a virtual memory system may be performedto determine which portion of the compression pool to swap out based onthe ordered segment lists in the compression pool. For example, thefarther away a segment is located in the ordered list from the headsegment, the more likely compressed data stored in the segment may nolonger be of interest (or of immediate need) for the working set. As aresult, the tail segment (or far end from the recording head) may beselected to be swapped out to a swap device. Compressed data may bebrought in/out from the compression pool from/to the swap device basedon compacted memory segments.

A need to perform memory swap operations may be identified, for example,to put an upper limit on the size of the compression pool. The size (orshape) of the compression pool may change dynamically based on runtimememory access patterns. In one embodiment, processing cost ofcompaction/compression/decompression operations vs. memory swapoperations may be dynamically monitored (or estimated) based on a cost(e.g. power consumption cost) model to determine when to perform swapoperations.

For example, the rate of compression, decompression and/or compactionoperations may correspond to power (or processing resource consumption)to indicate health of the compression pool (or compression layer,compression portion) in the memory device. If this rate exceeds acertain threshold, swap operations may be performed or trigged to pageout compressed data out of the compression pool to a swap device. In oneembodiment, compression/decompression and/or compaction operations mayincur a fraction of processing cost compared with data 10 transactionsin swap operations. Power cost functions may be evaluated to allow thecompression pool to grow before a need arises for paging out compresseddata to a swap device. The cost function may depend on, for example, theshape of the compression pool, configured tolerance in processinglatency caused by compaction/compression/decompression operations, orother applicable factors to maintain the working set in the memorydevice.

The compression pool in a memory device may allow power savings byreducing the required number of data paging (e.g. swap operations)to/from a swap device. For example, as data is compressed, less numberof data paging or file paging is required. Further, efficiency oreffectiveness in each data paging or swap operation can be improved withcompacted segments carrying the compressed data via log basedstructures.

In some embodiments, lists of log structure based memory segments in thecompression pool may be ordered corresponding to an age of compresseddata stored in each segment. The age of the compressed data may indicatehow early the data was compressed from the working set or accessed forthe working set. Swap operations may write out memory segments whichhave been aged (e.g. the tail portions of the ordered segment list) outof the working set. As a result, compressed data selected to be swappedout of the compression pool to a swap device (e.g. disk) may stored in acompacted memory segment which hasn't been used for a while. Swapoperations may be performed to, for example, make room for oraccommodate growth of the working set. In the meanwhile, periodic datawrite from the memory device to the swap device or disk device formaintenance purposes (e.g. file or data backup/synchronization) may beavoided or reduced with significant power saving.

The compression pool may provide mechanisms for speedy operations forsystem hibernation and/or waking up. For example, the compressed portionand uncompressed portion of a memory device may be separately backed up(or stored) in a non-volatile storage device (e.g. a disk) for a systemto enter a hibernated (or sleep) state. The compressed portion (orcompression pool) may be transferred (or pushed) to the non-volatilestorage device via compacted memory segments. The uncompressed portionof the memory (e.g. including a current working set) may be compressedinto the compression pool attached with special tags to be transferredto the non-volatile storage device as compacted memory segments. Forexample, applications may be suspended into the compression pool ascompressed/compacted memory segments.

During system waking up, the specially tagged compressed memory segmentscorresponding to the uncompressed portion of the memory device may beretrieved (or pulled back) from the non-volatile storage device topopulate the memory device with the previous working set (or hot workingset). For example, suspended applications may be unsuspended or restoredback to the uncompressed portion of the memory device from the speciallytagged compressed memory segments. Instead of retrieving arbitrarymemory pages (e.g. previously stored in either the compressed oruncompressed portions of the memory) associated with the applicationbeing restored, the system may be pre-heated (or pre-warmed foraccelerated waking up) with valuable information previously stored inthe uncompressed portion of the memory for the application beforeretrieving those memory pages previously stored in the compression pool.

FIG. 1 is a block diagram illustrating one embodiment of a virtualmemory system based on compressed and/or compacted memory. For example,system 100 may include operating environment 101 hosted in a memorydevice of a data processing device, such as a mobile device, a desktopcomputer, or a server, etc. The memory device may comprise, for example,a random access memory (RAM) for supporting data processing of at leastone processor in the processing device. Compressed memory (orcompression pool) 117 may be dynamically partitioned (or maintained)within the memory device. As a result, available memory space in thememory device for supporting operations of operating environment 101,which may be based on the uncompressed portion of the memory device, maybe less than the total memory space provided by the memory device. Incertain embodiments, multiple processors, such as CPUs, GPUs or otherapplicable processing units, can access compressed memory 117 inparallel.

In one embodiment, virtual memory management module 103 may virtualizevarious forms of computer data storage, such as RAM and mass storagedevices 121, to allow a program or process, such as application 123,running in operating environment 101 to access memory addresses (orvirtual memory addresses) as though there is only one kind of memory,namely virtual memory, which can behave like directly addressableread/write memory in RAM. For example, virtual memory management module103 can maintain mapping between virtual memory addresses (or a virtualmemory address) and actual physical data storage locations, such asphysical memory pages within the RAM (or memory device) and storagereferences in mass storage devices 121.

Virtual memory management module 103 may move data into or out of thememory device (e.g. RAM) via pager layer module 105. For example, data(e.g. anonymous data or dirty data not backed by a disk file in massstorage devices 121) may be swapped out of physical memory pages in thememory device to free up memory space in the physical memory pages inresponse to, for example, memory allocation requests from applicationsand/or other data processing requirements. Clean data (or memory data)which may be available from a disk file in mass storage devices 121 maybe paged out (or purged) from the memory device to increase availablememory space. When an application, such as application 123, terminates,memory space (e.g. stacks, heaps, etc.) allocated for the applicationmay become available for future allocation.

In one embodiment, virtual memory management module 103 may send memoryswapping in/out requests to pager layer module 105 to manage virtualmemory addresses within uncompressed portion of the memory device. Pagerlayer module 105 may interface with mass storage devices 121 and/orcompressed memory management module 107 to move memory pages to/from theuncompressed portion of the memory device. As a result, virtual memorymanagement module 103 can map a virtual memory address outside of theuncompressed portion of the memory device without distinguishing (orknowledge of) whether the virtual memory address corresponds to a memorylocation within compressed memory 117 or mass storage devices 121. Inother words, virtual memory management module 103 can be ignorant of thepresence of compressed memory 117.

Pager layer module 105 may be based on multiple concurrent threads (orinput/output threads) to perform memory paging operations. For example,pager layer module 105 may include a file pager to manage uncompressedmemory pages storing clean data from disk files of mass storage devices121. Pager layer module 105 may include memory pager (e.g. as one ormore threads) interfacing with compressed memory management module 107to move uncompressed memory pages to/from the uncompressed portion ofthe memory device via compressed memory 117.

In one embodiment, compressed memory 117 may include one or more logstructures (e.g. based on an array or queue having a head and a tail) tostore compressed memory units. Each log structure may include one ormore segments with buffers allocated for storing compressed memoryunits. Each segment may be of a common size (e.g. 256 KB, 512 KB, 1024KB, or other applicable sizes) with memory slots to store an orderedlist of compressed memory units (or compressed pages). Each compressedunit maybe may be compressed from a memory page in the uncompressedportion of a memory device, e.g. via compressor/decompressor module 111to the head of a log structure. In some embodiments, each log structurecan be updated or operated via separate threads concurrently and/orindependently via compressed memory management module 107.

A compressed memory unit may be stored in a memory slot (or position) inone segment of a log structure. Compressor module 111 can record orstore newly compressed memory page to a head slot of a log structure andupdate the next slot (to the current head slot) as the head slot of thelog structure for future compression. Compressed memory managementmodule 107 may create (or allocate from the uncompressed portion of amemory device) one or more new segments when the current segment (orhead segment in the log structure) becomes full (or substantially full).A mapping between a memory page and its corresponding compressed memoryunit in a log structure may be maintained for compressed memory 117, forexample, based on identifiers identifying a log structure, a segmentwithin the identified log structure and a memory slot within theidentified segment storing the compressed memory unit.

In one embodiment, compressor/decompressor module 111 can manage logstructures in compressed memory 117. Each log structure may beassociated with a recording head which may point to a head slot in acurrent segment, e.g. head segment in an array of segments in the logstructure. Multiple threads may be associated withcompressor/decompressor module 111 to perform memory compress/decompressoperations using separate log structures concurrently.Compressor/decompressor module 111 may perform compressing operationsaccording to a request queue storing memory pages to be compressed, forexample, as scheduled via pager layer module 105. A memory page whencompressed may require less than one page of physical memory size to bestored in a memory slot within a segment in a log structure.

In one embodiment, as more memory pages are compressed into compressedmemory 117, memory slots may be filled up following the head ofcorresponding log structure. Alternatively, some segments or slots inthe segments in the corresponding log structure may become empty oravailable for allocation when the stored compressed memory units arereleased. For example, when an application or process terminates,objects or structures maintained for the application may be removed andphysical memory pages or compressed memory units owned by theapplication may be released for future use (i.e. available forallocation). Alternatively, segments may become empty as a result ofbeing swapped out, decompressed or compacted.

Compressor/decompressor module 111 may pull or decompress compressedmemory units out of compressed memory 117 to the uncompressed portion ofa memory device, for example, in response to page faults encountered invirtual memory management module 103. Compressor/decompressor module 111may perform compressing and decompressing operations concurrently ondifferent segments of compressed memory 117, for example, via separatethreads.

Compressed memory management module 107 can include swap module 113 tomove segments of compressed memory units between compressed memory 117and mass storage device 121 via interface module 119. For example,segments of compressed memory units may be swapped out of compressedmemory 117 to make room for accommodating newly compressed memory pages,and/or to store a state of the memory device for future recovery duringsystem hibernation process etc. Alternatively, a segment of compressedmemory units may be swapped into compressed memory 117 because of pagefaults encountered in virtual memory management module 103 to accessdata in one or more of the segment of compressed memory units.

In one embodiment, one or more threads may be running for swap module113. A swap thread may wake up according to a designated schedule orresponding to requests. For example, pager layer module 105 may issuerequests to resolve page faults. Memory usage management module 115 maysend request to maintain enough available memory space in the memorydevice. According to one embodiment, a swap thread can wake up toexamine the current state of the memory device to determine how manysegments of compressed memory units to swap out of compressed memory117. The swap thread can select a least used (e.g. aged or old) segment,compact it (e.g. via compaction module 109) if needed, and forward theselected segment to mass storage devices 121. Swapping operations viaswap module 113 may be performed independent and/or concurrently withcompression/decompression operations via compressor/decompressor module111.

Compaction module 109 may perform compaction operations on compressedmemory 117 to reduce memory fragmentation and/or to increase memoryswapping efficiencies. For example, compaction module 109 can performminor compaction operations to slide (or move) compressed memory unitswithin a segment of a log structure without altering orderingrelationship among the compressed memory units to consolidate emptymemory slots left in between. Alternatively or optionally, compactionmodule 109 can perform major compaction operations to move compressedmemory units across different segments to fill up and/or empty certainsegments.

In one embodiment, swap module 113 may request compaction module 109 tocompact segments (e.g. minimize or reduce empty slots) for betterswapping performance. For example, the interface between a memory deviceand a swap device may be based on a fixed size data buffer for datatransfer. A tightly packed segment matching the data buffer size canmaximize transfer efficiency (e.g. amount of data transferred per unittime or clock cycle).

Memory usage management module 115 may determine when to push out orswap out compressed memory units or pages from compressed memory 117 tomass storage devices 121. Memory usage management module can monitorusage status of the memory device to provide triggers for (or sendrequest to) swap module 113 to initiate swapping operations. Usagestatus may include power usage, memory performance (e.g. read/writespeed), memory usage rate, ratio of compressed/uncompressed partitionsin the memory device, size of compressed memory 117, size of working setof memory pages, or other applicable runtime measures, etc.

FIG. 2 is a flow diagram illustrating one embodiment of compressing anddecompressing memory for a virtual memory. For example, process 200 maybe performed by some components of system 100 of FIG. 1. At block 201,the processing logic of process 200 can dynamically update a compressedportion of memory in a memory device for a virtual memory supporting oneor more processors. The memory device can include an uncompressedportion of memory separate from the compressed portion of memory. Amemory address in the virtual memory may be mapped into the compressedportion or the uncompressed portion of the memory.

In one embodiment, the compressed portion of memory may be updated withadditional memory allocated from the uncompressed portion of memory. Amemory region allocated in the uncompressed portion of memory may becompressed into the compressed portion of memory to allow the memoryregion to be available for future allocation in the uncompressed portionof memory of the memory device. The updated compressed portion of memorymay be capable of storing the compressed memory region. The size ofavailable memory for allocation in the uncompressed portion of memorymay increase as a result of the compression of the memory region.

According to one embodiment, the compressed memory region may bedecompressed back to the uncompressed portion in the memory device, forexample, in response to receiving a request to access data in thecompressed memory region. The processing logic of process 200 maydetermine if the requested data is currently available in theuncompressed portion of memory. If the requested data is not currentlyavailable in the uncompressed portion of memory, the request may cause apage fault event to trigger the update on the compressed portion ofmemory, e.g. to uncompress the compressed memory region.

The compressed portion of memory may be stored in multiple (or at leastone) compressed memory units. Each compressed memory unit may correspondto a separate memory region compressed from the uncompressed portion ofmemory. Separate compressed memory units may not be stored consecutively(e.g. based on physical allocation within the memory device) in thecompressed portion of memory. In one embodiment, the compressed portionof memory may be compacted to cause these separate compressed memoryunits to be stored consecutively in the compressed portion of memory.

A memory region may correspond to a memory unit of a fixed size, such asa page of memory, in the uncompressed portion of a memory device. Acompressed memory unit may vary in size depending on, for example,amount or compression property of original data content compressed intothe compressed memory unit. In one embodiment, a compressed memoryregion may correspond to a particular compressed memory unit in thecompressed portion of memory.

In one embodiment, a particular compressed memory unit may be stored inbetween adjacent compressed memory units in the compressed portion ofmemory. When the particular compressed memory unit is removed from thecompressed portion of memory, the adjacent memory units may be moved tobe stored consecutively next to each other, e.g. via compactionoperations. The particular compressed memory unit may be removed fromthe compressed portion of memory via, for example, decompressionoperation, swapping operations, or other applicable memory managementoperations.

In some embodiments, the compressed portion of memory may includemultiple pools of memory slots. Each compressed memory unit may bestored in one or more consecutive (according to physical memoryallocation) memory slots. Each pool may correspond to a separatepartition of the compressed memory units. In one embodiment, each poolmay be associated with a separate thread, e.g. belonging to a processrunning in a system using the memory. Compaction operations on thecompressed portion of memory may be separately and asynchronouslyperformed for each pool via its associated thread.

The memory device may be coupled with a separate storage device, such asa hard disk, a flash memory or other applicable non-volatile storagedevice. One or more of the compressed memory units may be swapped out tothe separate storage device from the compressed portion of memory (e.g.to update the compressed portion of memory). As a result, the size ofthe compressed portion of memory may be decreased to increase the sizeof the uncompressed portion of memory. Alternatively, the compressedmemory units for compressed memory regions may be swapped to thecompressed portion of memory from the separate storage device if data inthe compressed memory units are not currently available in thecompressed portion of memory when requested.

The processing logic of process 200 may swap compressed memory unitsbetween the storage device (e.g. a swap device) and the memory devicevia an interface having a data transfer buffer, such as a bus bufferwith a certain bit size. In one embodiment, the processing logic ofprocess 200 may compact the compressed portion of memory to allow thedata transfer buffer to efficiently carry multiple compressed memoryunits together, for example, with substantially full capacity in eachhardware data transaction.

In one embodiment, the memory region may correspond to a memory page inthe memory device. The uncompressed portion of memory can include aworking set of memory pages to support currently active data processingprocesses. The working set of memory pages may be compressed into aseries of compressed memory units in the compressed portion of memory,for example, in response to a hibernation request to temporarily haltoperations of the system. The series of compressed memory units can thenbe swapped out to a storage device coupled with the memory device forfuture use.

The processing logic of process 200 can select at least one compressedmemory units to swap out of the compressed portion of memory. Theselection may be based on usage properties of the compressed memoryunits. The usage properties may indicate when data is accessed for thecompressed memory units. For example, the usage properties may includetime stamps or other meta data associated with a compressed memory unitto indicate when the compressed memory unit was accessed, created,compressed, swapped in, or used etc.

In one embodiment, the processing logic of process 200 may swap out thecompressed memory units which are least likely to be used or requestedfor the working set, such as via a LRU strategy. The processing logic ofprocess 200 may heuristically determine likelihood of the compressedmemory units to be accessed in the near future based on associated usageproperties. In one embodiment, the compressed memory units may be storedlinearly with an order in the compressed portion of memory. The ordermay correspond to the usage properties (e.g. access time stamps)associated with the compressed memory units.

The compressed portion of memory may include one or more memorysegments. Each memory segment can correspond to an array of one or moreof the compressed memory units. The processing logic of process 200 canmove or slide one or more compressed memory units within a particularmemory segment for performing compaction operations to allow multiplecompressed memory units to be stored in contiguous memory space withinthe particular memory segment.

In one embodiment, each memory segment can have a memory capacity and/ora usage rate. The usage rate can indicate how much of the memorycapacity has been used to store a corresponding array of compressedmemory units. The processing logic of process 200 can perform thecompaction operations to move one or more of the compressed memory unitsacross the memory segments to increase the usage rate of at least one ofthe memory segments. For example, a memory segment which is 60% full maybecome 99% full after the compaction operations.

FIG. 3 is a flow diagram illustrating one embodiment of a process toswap compressed memory pages for a virtual memory. For example, process300 may be performed by some components of system 100 of FIG. 1. Atblock 301, the processing logic of process 300 can provide a virtualmemory based on a memory device. The processing logic of process 300 maydynamically partition the memory device into an uncompressed portion (orlayer) of memory and a compressed portion (or layer) of memory. Aworking set of memory space used to perform data processing tasks by oneor more processors coupled to the memory device may be stored in theuncompressed portion of memory.

At block 303, the processing logic of process 300 can compress one ormore memory pages of the uncompressed portion of memory into one or morevaried sized compressed memory units in the compressed portion ofmemory. The compression can increase available memory space in theuncompressed portion of memory.

At block 305, the processing logic of process 300 can decompress aparticular one of the compressed memory units from the compressedportion of memory to the uncompressed portion of memory, for example, inresponse to a page fault as a result of an access request to data in theparticular compressed memory unit.

At block 307, the processing logic of process 300 may swap out at leastone varied sized compressed memory unit from the compressed portion ofmemory to the mass storage device to increase available memory space inthe uncompressed portion of memory, for example, to accommodateadditional allocation requirement for the working set in theuncompressed portion of memory.

FIG. 4 is a flow diagram illustrating one embodiment of a process toswap a compacted segment of compressed memory for a virtual memory. Forexample, process 400 may be performed by some components of system 100of FIG. 1. At block 401, the processing logic of process 400 cancompress one or more memory pages of an uncompressed portion of a memorydevice into one or more varied sized compressed memory units in acompressed portion of the memory device. The memory device may becoupled with a mass storage device.

At block 403, the processing logic of process 400 may compact the variedsized compressed memory units into a segment or other applicable logstructure data in the compressed portion of the memory device.

In response to receiving an access request to compressed data in one ofthe compressed memory units, at block 405, the processing logic ofprocess 400 can decompress one or more compressed memory units, forexample, from the segment in the compressed portion to the uncompressedportion of the memory device.

At block 407, the processing logic of process 400 can swap out thesegment of the compressed memory units to the mass storage device toincrease available memory space in the memory device.

FIG. 5 shows one example of a data processing system, such as a computersystem, which may be used with one embodiment the present invention. Forexample, system 1 of FIG. 1 may be implemented as a part of the systemshown in FIG. 5. Note that while FIG. 5 illustrates various componentsof a computer system, it is not intended to represent any particulararchitecture or manner of interconnecting the components as such detailsare not germane to the present invention. It will also be appreciatedthat network computers and other data processing systems which havefewer components or perhaps more components may also be used with thepresent invention.

As shown in FIG. 5, the computer system 500, which is a form of a dataprocessing system, includes a bus 503 which is coupled to amicroprocessor(s) 505 and a ROM (Read Only Memory) 507 and volatile RAM509 and a non-volatile memory 511. The microprocessor 505 may retrievethe instructions from the memories 507, 509, 511 and execute theinstructions to perform operations described above. The bus 503interconnects these various components together and also interconnectsthese components 505, 507, 509, and 511 to a display controller anddisplay device 513 and to peripheral devices such as input/output (I/O)devices which may be mice, keyboards, modems, network interfaces,printers and other devices which are well known in the art. Typically,the input/output devices 515 are coupled to the system throughinput/output controllers 517. The volatile RAM (Random Access Memory)509 is typically implemented as dynamic RAM (DRAM) which requires powercontinually in order to refresh or maintain the data in the memory.

The mass storage 511 is typically a magnetic hard drive or a magneticoptical drive or an optical drive or a DVD RAM or a flash memory orother types of memory systems which maintain data (e.g. large amounts ofdata) even after power is removed from the system. Typically, the massstorage 511 will also be a random access memory although this is notrequired. While FIG. 5 shows that the mass storage 511 is a local devicecoupled directly to the rest of the components in the data processingsystem, it will be appreciated that the present invention may utilize anon-volatile memory which is remote from the system, such as a networkstorage device which is coupled to the data processing system through anetwork interface such as a modem or Ethernet interface or wirelessnetworking interface. The bus 503 may include one or more busesconnected to each other through various bridges, controllers and/oradapters as is well known in the art.

Portions of what was described above may be implemented with logiccircuitry such as a dedicated logic circuit or with a microcontroller orother form of processing core that executes program code instructions.Thus processes taught by the discussion above may be performed withprogram code such as machine-executable instructions that cause amachine that executes these instructions to perform certain functions.In this context, a “machine” may be a machine that converts intermediateform (or “abstract”) instructions into processor specific instructions(e.g., an abstract execution environment such as a “virtual machine”(e.g., a Java Virtual Machine), an interpreter, a Common LanguageRuntime, a high-level language virtual machine, etc.), and/or,electronic circuitry disposed on a semiconductor chip (e.g., “logiccircuitry” implemented with transistors) designed to executeinstructions such as a general-purpose processor and/or aspecial-purpose processor. Processes taught by the discussion above mayalso be performed by (in the alternative to a machine or in combinationwith a machine) electronic circuitry designed to perform the processes(or a portion thereof) without the execution of program code.

An article of manufacture may be used to store program code. An articleof manufacture that stores program code may be embodied as, but is notlimited to, one or more memories (e.g., one or more flash memories,random access memories (static, dynamic or other)), optical disks,CD-ROMs, DVD ROMs, EPROMs, EEPROMs, magnetic or optical cards or othertype of machine-readable media suitable for storing electronicinstructions. Program code may also be downloaded from a remote computer(e.g., a server) to a requesting computer (e.g., a client) by way ofdata signals embodied in a propagation medium (e.g., via a communicationlink (e.g., a network connection)).

The preceding detailed descriptions are presented in terms of algorithmsand symbolic representations of operations on data bits within acomputer memory. These algorithmic descriptions and representations arethe tools used by those skilled in the data processing arts to mosteffectively convey the substance of their work to others skilled in theart. An algorithm is here, and generally, conceived to be aself-consistent sequence of operations leading to a desired result. Theoperations are those requiring physical manipulations of physicalquantities. Usually, though not necessarily, these quantities take theform of electrical or magnetic signals capable of being stored,transferred, combined, compared, and otherwise manipulated. It hasproven convenient at times, principally for reasons of common usage, torefer to these signals as bits, values, elements, symbols, characters,terms, numbers, or the like.

It should be kept in mind, however, that all of these and similar termsare to be associated with the appropriate physical quantities and aremerely convenient labels applied to these quantities. Unlessspecifically stated otherwise as apparent from the above discussion, itis appreciated that throughout the description, discussions utilizingterms such as “processing” or “computing” or “calculating” or“determining” or “displaying” or the like, refer to the action andprocesses of a computer system, or similar electronic computing device,that manipulates and transforms data represented as physical(electronic) quantities within the computer system's registers andmemories into other data similarly represented as physical quantitieswithin the computer system memories or registers or other suchinformation storage, transmission or display devices.

The present invention also relates to an apparatus for performing theoperations described herein. This apparatus may be specially constructedfor the required purpose, or it may comprise a general-purpose computerselectively activated or reconfigured by a computer program stored inthe computer. Such a computer program may be stored in a computerreadable storage medium, such as, but is not limited to, any type ofdisk including floppy disks, optical disks, CD-ROMs, andmagnetic-optical disks, read-only memories (ROMs), RAMs, EPROMs,EEPROMs, magnetic or optical cards, or any type of media suitable forstoring electronic instructions, and each coupled to a computer systembus.

The processes and displays presented herein are not inherently relatedto any particular computer or other apparatus. Various general-purposesystems may be used with programs in accordance with the teachingsherein, or it may prove convenient to construct a more specializedapparatus to perform the operations described. The required structurefor a variety of these systems will be evident from the descriptionbelow. In addition, the present invention is not described withreference to any particular programming language. It will be appreciatedthat a variety of programming languages may be used to implement theteachings of the invention as described herein.

The foregoing discussion merely describes some exemplary embodiments ofthe present invention. One skilled in the art will readily recognizefrom such discussion, the accompanying drawings and the claims thatvarious modifications can be made without departing from the spirit andscope of the invention.

What is claimed is:
 1. A machine-readable non-transient storage mediumhaving instructions stored therein, which when executed by a computer,cause the computer to perform a method comprising: dynamically updatinga compressed portion of memory in a memory device for a virtual memory,the memory device including an uncompressed portion of memory separatefrom the compressed portion of memory, the virtual memory capable ofmapping a memory address to the compressed portion of memory;compressing a memory region allocated in the uncompressed portion ofmemory into the compressed portion of memory, wherein the memory regionbecomes available for future allocation in the memory device, whereinthe updated compressed portion is capable of storing the compressedmemory region; and in response to a request to access data in thecompressed memory region, decompressing the compressed memory regionback to the uncompressed portion in the memory device.
 2. The medium ofclaim 1, wherein the request causes a page fault which indicates thedata is not available in the uncompressed portion of memory.
 3. Themedium of claim 1, wherein the update comprises: allocating additionalmemory from the uncompressed portion of memory for the compressedportion of memory, wherein size of available memory for allocation inthe uncompressed portion of memory increases as a result of thecompression of the memory region.
 4. The medium of claim 1, wherein thecompressed portion of memory stores a plurality of compressed memoryunits, each compressed memory unit corresponding to a separate memoryregion compressed from the uncompressed portion of memory, wherein atleast two of the compressed memory units are not stored consecutively inthe compressed portion of memory, further comprising: compacting thecompressed portion of memory, wherein the compacting causes the at leasttwo of the compressed memory units to be stored consecutively in thecompressed portion of memory.
 5. The medium of claim 4, wherein thecompressed memory region corresponds to a particular compressed memoryunit in the compressed portion of memory, wherein the particularcompressed memory unit was stored in between the at least two compressedmemory units, wherein the decompression removes the particularcompressed memory unit from the compressed portion of memory to allowthe at least two of the compressed memory units to be storedconsecutively.
 6. The medium of claim 4, wherein the memory device iscoupled with a separate storage device, wherein the update comprises:swapping out one or more of the compressed memory units from thecompressed portion of memory to the separate storage device, wherein theswapping out causes a decrease in size of the compressed portion ofmemory to increase size of the uncompressed portion of memory.
 7. Themedium of claim 6, further comprising: determining if the data of thecompressed memory region for the request is currently available in thecompressed portion of memory, wherein the compressed memory region isdecompressed if the data of the compressed memory region is currentlyavailable in the compressed portion of memory.
 8. The medium of claim 7,further comprising: swapping in the compressed memory region from theseparate storage device to the compressed portion of memory if the dataof the compressed memory region is not currently available in thecompressed portion of memory.
 9. The medium of claim 6, wherein aparticular one of the one or more of the compressed memory units wasstored in between the at least two compressed memory units, wherein theswapping out removes the particular compressed memory unit from thecompressed portion of memory to allow the at least two of the compressedmemory units to be stored consecutively.
 10. The medium of claim 6,wherein the swapping out comprises: selecting the one or more of thecompressed memory units for the swapping and wherein the selection isbased on usage properties associated with the compressed memory units.11. The medium of claim 10, wherein the memory region corresponds to amemory unit of a fixed size in the memory device, wherein the compressedmemory units are of varied sizes, and wherein the compressed memoryunits are stored linearly with an order in the compressed portion ofmemory.
 12. The medium of claim 11, wherein the usage propertiescorresponds to the linear order associated with the compressed memoryunits.
 13. The medium of claim 12, wherein usage properties indicatewhen data is accessed for the compressed memory units and wherein theone or more of the compressed memory units selected are least recentlyused according to the linear order for the selection.
 14. The medium ofclaim 11, wherein the memory device is coupled with the separate storagedevice via an interface having a data transfer buffer, wherein theswapping is based on data transfer over the interface via the datatransfer buffer, and wherein the compaction allows the data transferbuffer to carry a plurality of the compressed memory units together. 15.The medium of claim 11, wherein the compressed portion of memoryincludes one or more memory segments, each memory segment corresponds toan array of one or more of the compressed memory units, a particulararray of one of the memory segments includes two or more compressedmemory units, the compacting comprises: moving at least one of thecompressed memory units within the particular memory segment such thetwo or more compressed memory units are stored in contiguous memoryspace within the particular memory segment.
 16. The medium of claim 15,wherein each memory segment has a memory capacity, each memory segmenthaving a usage rate indicating how much of the memory capacity has beenused to store corresponding array of compressed memory units, thecompacting further comprising: moving one or more of the compressedmemory units across the memory segments, wherein corresponding usagerate of at least one of the memory segments increases as a result themoving of the one or more of the compressed memory units.
 17. The mediumof claim 4, wherein the compressed portion of memory includes multiplepools of memory slots, each compressed memory unit stored in one or moreconsecutive ones of the memory slot, each pool corresponding to aseparate partition of the compressed memory units, each pool isassociated with a separate thread and wherein the compaction isseparately and asynchronously performed for each pool via associatedthread.
 18. The medium of claim 6, wherein the memory region correspondsto a memory page in the memory device, wherein the uncompressed portionof memory includes a working set of memory pages to support currentlyactive data processing processes, further comprising: in response to ahibernation request, compressing the working set of memory pages to aseries of compressed memory units in the compressed portion of memory;and swapping out the series of compressed memory units to the storagedevice.
 19. A machine-readable non-transient storage medium havinginstructions stored therein, which when executed by a computer, causethe computer to perform a method comprising: providing a virtual memorybased on a memory device, the memory device dynamically partitioned intoan uncompressed portion of memory and a compressed portion of memory,the uncompressed portion of memory to store working data processed via aprocessor coupled to the memory device; compressing one or more memorypages of the uncompressed portion of memory into one or more variedsized compressed memory units in the compressed portion of memory,wherein the compression increases available memory space in theuncompressed portion of memory; in response to a page fault for anaccess request to data in one of the compressed memory units,decompressing the one compressed memory units from the compressedportion of memory to the uncompressed portion of memory; and swappingout at least one of the varied sized compressed memory units from thecompressed portion of memory to the mass storage device, wherein theswapping out increases available memory space in the uncompressedportion of memory.
 20. A machine-readable non-transient storage mediumhaving instructions stored therein, which when executed by a computer,cause the computer to perform a method comprising: compressing one ormore memory pages of a uncompressed portion of a memory device into oneor more varied sized compressed memory units in a compressed portion ofthe memory device, the memory device coupled with a mass storage device;compacting the varied sized compressed memory units into a segment inthe compressed portion of the memory device; in response to accessrequest to one of the compressed memory units, decompressing the onecompressed memory unit from the compressed portion to the uncompressedportion of the memory device; and swapping out the segment of thecompressed memory units to the mass storage device to increase availablememory space in the memory device.
 21. A computer implemented methodcomprising: dynamically updating a compressed portion of memory in amemory device, the memory device including an uncompressed portion ofmemory capable of supporting data processing for at least one processor;compressing a memory region allocated in the uncompressed portion ofmemory into the compressed portion of memory, wherein the memory regionbecomes available for future allocation in the memory device, whereinthe updated compressed portion is capable of storing the compressedmemory region; and in response to a request to access data in thecompressed memory region, decompressing the compressed memory regionback to the uncompressed portion in the memory device.
 22. A computersystem comprising: a memory including executable instructions, thememory dynamically partitioned into a compressed portion and anuncompressed portion; a mass storage device; a processor coupled to thememory and the mass storage device, the processor to execute theexecutable instructions from the memory, the processor being configuredto compress a memory region allocated in the uncompressed portion ofmemory into the compressed portion of memory, wherein the memory regionbecomes available for future allocation in the memory device, whereinthe updated compressed portion is capable of storing the compressedmemory region; in response to a request to access data in the compressedmemory region, decompressing the compressed memory region back to theuncompressed portion in the memory device; and in response to detectinga high memory usage in the memory device, swap out the compressed memoryregion to the storage device to increase available memory space in thememory device